package com.gk.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.eight.pojo.CouponHistory;
import com.eight.pojo.TbCoupon;
import com.eight.pojo.TbIntegrationHistory;
import com.eight.util.TimeUtil;
import com.eight.vo.ComResult;
import com.gk.dao.CouponHistoryDao;
import com.gk.dao.TbIntegrationHistoryDao;
import com.gk.fein.UserEnableCouponFein;
import com.gk.service.TbIntegrationHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author: GK
 * @date: 2023/3/2 9:21
 * @version:No1.0
 */
@Service
public class TbIntegrationHistoryServiceImpl extends ServiceImpl<TbIntegrationHistoryDao, TbIntegrationHistory> implements TbIntegrationHistoryService {

    @Resource
    private TbIntegrationHistoryDao historyDao;
    @Resource
    private CouponHistoryDao couponHistoryDao;
    @Autowired
    private UserEnableCouponFein userEnableCouponFein;


    /**
     * 条件分页查询
     *
     * @param history     查询条件
     * @param currentPage 当前页
     * @param pageSize    页中数据数量
     * @return 响应前端
     */
    @Override
    public ComResult selectAll(TbIntegrationHistory history, Integer currentPage, Integer pageSize) {
        Page<TbIntegrationHistory> page = new Page<>(currentPage, pageSize);
        page = historyDao.selectAll(page, history);
        if (page != null) {
            return new ComResult(2000, "查询成功", page);
        } else {
            return new ComResult(5000, "查询失败");
        }
    }

    /**
     * 根据ID号删除积分记录
     *
     * @param id ID号
     * @return 响应前端
     */
    @Override
    public ComResult deleteId(Integer id) {
        int i = historyDao.deleteById(id);
        if (i > 0) {
            return new ComResult(2000, "删除成功");
        } else {
            return new ComResult(5000, "删除失败");
        }
    }

}
